import { inject } from 'vue'
import api from '../../../api/search'

const search_form = inject('search_form')

const search = async ({ params }) => {
  // 更新 form
  search_form = Object.assign(search_form, params)
  try {
    const res = await api.search(search_form)
    // Todo：更新 data 到全局
    data = res.data.list
  } catch (err) {
    console.log(err)
  }
}

export default function useSearch() {
  return {
    search,
  }
}
